<?php
// Convert from dash separator -> CamelCase
function dashToCamelCase($s, $ucfirst = true) {
    $s = preg_replace('/-(.?)/', "strtoupper('$1')", $s);
    if ($ucfirst) {
        return ucfirst($s);
    }
    return $s;
}

// Convert from dash separator -> CamelCase
function camelCaseToDash($s) {
    return strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1-$2", $s)); 
}

// Get URI for static files
function asset($path){
    return BASE_URL.$path;
}

function isRoute($controller, $action){
    global $request;
    if ( $request->getParam('controller') === $controller && $request->getParam('action') === $action ){
        return true;
    }
    return false;
}

function url($path, array $params = null){
    $url = BASE_URL.'index.php/'.$path;
    $parameters = array();
    if ( $params ){
        foreach ($params as $key => $param) {
            $parameters[] = $key.'='.$param;
        }
    }
    $str = implode('&amp;', $parameters);
    return $url.( $str ? '?'.$str : '' );
}